import React, {PureComponent} from "react"
import { Form } from '@ant-design/compatible';
import '@ant-design/compatible/assets/index.css';
import { Alert, Button, Input, Tooltip, Spin } from "antd";
import myShopCompose from "./compose"
import NoShop from "./components/no-shop"
import UnderReview from "./components/under-review"
import Shops from "./components/shops"
import Rejected from "./components/rejected"
import "./index.less"

export default @myShopCompose class MyShopPage extends PureComponent {

  shopRender = (_shopData) => {
    if (_shopData === null) {
      return <div className={'shop-data-loading'}><Spin size={'large'}/></div>
    }

    if (_shopData.length < 1) {
      return <NoShop/>
    }

    if (_shopData.length === 1
      && (_shopData[0]['status'] === 'firstUnderReview'
        || _shopData[0]['status'] === 'updateUnderReview')) {
      return <UnderReview/>
    }

    if (_shopData.length === 1 && _shopData[0]['status'] === 'reject') {
      return <Rejected data={_shopData}/>
    }

    return <Shops data={_shopData}/>
  }

  render() {
    const {
      _shopData
    } = this.props

    return (
      <div className={'my-shop-page ld2-content-page absolute'}>
        {
          this.shopRender(_shopData)
        }
      </div>
    )
  }
}